package com.bonc.apicreator.dao;


import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

import com.bonc.apicreator.entity.RestApiResponse;


/**
 * ApiResponse的dao层接口
 *
 * @author gaopengyu
 * @version 2016年8月5日
 * @see ApiResponseDao
 * @since
 */
@Transactional
public interface ApiResponseDao extends JpaRepository<RestApiResponse, Long> {

    /**
     * Description: 查询所属该api的响应
     * 
     * @param apiId
     * @return List<RestApiResponse>
     * @see
     */
    List<RestApiResponse> findByApiId(Long apiId);

    /**
     * Description: 重名校验
     * 
     * @param apiId
     * @param code
     * @return RestApiResponse
     * @see
     */
    RestApiResponse findByApiIdAndCode(Long apiId, String code);

    /**
     * Description: 按对应字段名排序
     * 
     * @param apiId
     * @return List<RestApiResponse>
     * @see
     */
    List<RestApiResponse> findByApiIdOrderByColumnNameAsc(Long apiId);

    /**
     * Description: 查询父节点下的所有子节点
     * 
     * @param responseId
     * @return List<RestApiResponse>
     * @see
     */
    List<RestApiResponse> findByTopId(Long responseId);

    /**
     * Description: 查询父节点下的所有子节点并排序
     * 
     * @param responseId
     * @return List<RestApiResponse>
     * @see
     */
    List<RestApiResponse> findByTopIdOrderByNodeIdAsc(Long responseId);

    /**
     * Description: 删除所有子节点
     * 
     * @param id
     *            void
     * @see
     */
    void deleteByTopId(long id);

    /**
     * 返回dataType是count的响应信息
     * Description: 
     * 
     *@param apiId
     *@param count
     *@return RestApiResponse
     *
     * @see
     */
    RestApiResponse findByApiIdAndDataType(Long apiId, String count);

}
